package cn.org.dian.easycommunicate;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import cn.org.dian.easycommunicate.model.DataCenter;
import cn.org.dian.easycommunicate.util.Utilities;

public class ThemeSelectActivity extends ListActivity {

//    private static final String TAG = "ThemeSelectActivity";fgd

    /*
     * (non-Javadoc)
     * 
     * @see android.app.Activity#onCreate(android.os.Bundle)
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        ListAdapter listAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, DataCenter
                        .getAllThemeName());
        setListAdapter(listAdapter);

    }

    /*
     * (non-Javadoc)
     * 
     * @see android.app.ListActivity#onListItemClick(android.widget.ListView,
     * android.view.View, int, long)
     */
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        Intent intent = new Intent(this, ThemeActivity.class);
        // use multiple mode
//        intent.putExtra("mode", Constants.MODE_MULTIPLE);
        // pass theme_indicator to next Activity
        intent.putExtra("theme_indicator", position);
        // pass language_indicator from last Activity to next Activity
        int languageIndicator = getIntent()
                .getIntExtra("language_indicator", 0);
        intent.putExtra("language_indicator", languageIndicator);
        startActivity(intent);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return Utilities.onCreateOptionsMenu(this, menu);
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        return Utilities.onOptionsItemSelected(this, item);
    }
}
